﻿using IServices;
using System;
using System.Collections.Generic;
using System.Text;
using YL.Core.Entity;
using SqlSugar;
using IRepository;
using YL.Utils.Files;
using System.Threading.Tasks;
using YL.Utils.Extensions;

namespace Services
{
    public class Whr_minio_fileServices : BaseServices<Whr_mio_file>, IWhr_minio_fileServices
    {
        private readonly SqlSugarClient _client;
        public Whr_minio_fileServices(SqlSugarClient client, IWhr_minio_fileRepository repository) : base(repository) 
        {
            _client = client;
        }

        public async Task<string> GetObjectUrl(string uuid) 
        {
            if (uuid.IsNull() || uuid.IsEmpty()) return "";
            var entity = _client.Queryable<Whr_mio_file>().Where(s => s.ObjectId == uuid).First();
            if (entity != null) 
            {
                var url = await MinioUtil.GetMinioObject(entity.BucketName, entity.FileName);
            }
            return "";
        }
    }
}
